﻿@using KRM.Core
@model tblPermissionPageRole
@{
    ViewBag.Title = "Page role";
    Layout = "~/Views/Shared/_Layout.cshtml";
    List<tblPermissionPageRole> lstPage = ViewBag.lstPage;
    tblPermissionRole Role = ViewBag.role;
}

<div class="container-fluid">
    <div class="box">
        <div class="box-title">
            <h3><i class="icon-edit"></i>Add page on the @Role.Name</h3>
        </div>
        <div class="box-content">
            @if (!string.IsNullOrEmpty(ViewBag.msg) && ViewBag.msg == "success")
            {
                <div class="alert alert-success">
                    <button type="button" class="close" data-dismiss="alert">×</button>
                    <strong>Success!</strong>
                </div>
            }
            @using (Html.BeginForm("PageRole", "Permission", FormMethod.Post, new { @class = "form-horizontal" }))
            {
                <input type="hidden" name="RoleId" value="@Role.Id"/>
                <div class="control-group">
                    <label class="control-label" for="TypePage">Type page</label>
                    <div class="controls">
                        @Html.DropDownList("TypePage", null, new { @onchange="typepagechange(this.value);" })
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="PageId">Page</label>
                    <div class="controls">
                        @Html.DropDownList("PageId", null, new {@required="required"})
                    </div>
                </div>
                <div class="form-actions">
                    <button type="submit" class="btn btn-primary">Add</button>
                    <input type="button" class="btn" onclick="javascript: window.location = '/permission/role';" value="Cancel">
                </div>
            }
        </div>
        
        <div class="row-fluid">
            <table class="table table-hover table-bordered table-fix">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Page name</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in lstPage)
                    {
                        <tr>
                            <td>
                                @item.Id
                            </td>
                            <td>@item.tblPermissionPage.Name</td>
                            <td><a href="/permission/deletepagerole?id=@item.Id&role=@Role.Id&typepage=@item.tblPermissionPage.TypePageId" onclick="javascript:return confirm('Are you sure?');">Delete</a></td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>

    </div>
</div>

